#include <bits/stdc++.h>
using namespace std;
long long T, n, m, L, V, q[10010][10010];
vector <int> p;
struct node{
    long long d, v, a;
}car[100010];
int many(){
    long long ans = 0;
    for(int i = 1;i <= n;i ++){
        int ph = 0;
        if(car[i].a == 0){
            if(car[i].v > V){
                for(int j = 0;j < m;j ++){
                    if(p[j] >= car[i].d){
                        ph ++;
                        q[p[j]][i] = 1;
                    }
                }
            }
        }else if(car[i].v >= V){
            double pl = (V * V - car[i].v * car[i].v) * 1.0 / (2 * car[i].a) + car[i].d;
            for(int j = 0;j < m;j ++){
                if(p[j] >= car[i].d && p[j] < pl){
                    ph ++;
                    q[p[j]][i] = 1;
                }
            }
        }else{
            double pl = (V * V - car[i].v * car[i].v) * 1.0 / (2 * car[i].a) + car[i].d;
            for(int j = 0;j < m;j ++){
                if(p[j] > pl){
                    ph ++;
                    q[p[j]][i] = 1;
                }
            }
        }
        if(ph){
            ans ++;
        }
    }
    return ans;
}
int find(){
    int maxx = -1, pos;
    for(int i = 1;i <= m;i ++){
        if(maxx < q[i][0]){
            maxx = q[i][0];
            pos = i;
        }
    }
    return pos;
}
int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    cin >> T;
    while(T --){
        cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;i ++){
            cin >> car[i].d >> car[i].v >> car[i].a;
        }
        for(int i = 0;i < m;i ++){
            int tmp;
            cin >> tmp;
            p.push_back(tmp);
        }
        int tmp = many(), ans = 0;
        cout << tmp << ' ';
        for(int i = 1;i <= m;i ++){
            for(int j = 1;j <= n;j ++){
                q[i][0] += q[i][j];
            }
        }
        while(q[find()][0] != 0){
            int tmp = find();
            for(int i = 1;i <= n;i ++){
                for(int j = 1;j <= m;j ++){
                    for(int k = 1;k <= n;k ++){
                        if(q[j][k] == q[tmp][i] && (j != tmp || k != i)){
                            q[j][k] = 0;
                            q[j][0] --;
                        }
                    }
                }
                q[tmp][i] = 0;
                q[tmp][0] --;
            }
            ans ++;
        }
        cout << m - ans << endl;
    }
    return 0;
}
